/**
 * Redux的使用第四步：异步状态操作
 */
import {useEffect } from "react";
import { useSelector,useDispatch } from "react-redux";
import { AsyncGetImg } from "../../../store/modules/channelStore";

function useGetChannelRedux() {
    const { img } = useSelector((state) => state.channel);

    const dispatch = useDispatch();

    // 使用异步useEffect触发异步执行
    useEffect(() => {
        dispatch(AsyncGetImg());
    }, [dispatch]);

    return <img src={img} />;
}


export default useGetChannelRedux